﻿@{
    ViewBag.Title = "添加客户";
}
<style type="text/css">
    table
    {
        border: 0px;
    }

    .left
    {
        margin: 15px;
    }

    tr
    {
        line-height: 35px;
    }

    .textLeft
    {
        text-align: right;
    }
</style>

<div style="width: 100%;">
    <div class="mini-toolbar" style="border-bottom: 0; padding: 0px;">
        <table style="width: 100%;">
            <tr>
                <td style="width: 100%;">
                    <a class="mini-button" iconcls="icon-save" plain="true" onclick="saveData(this)">保存</a>
                </td>
            </tr>
        </table>
    </div>
</div>
<div id="addData">
    <table class="left">
        <tr>
            <td class="textLeft">客户编号：</td>
            <td>

                <input id="textbox1" name="CustomerCode" class="mini-textbox" style="width: 150px;" required="true" /></td>
            <td class="textLeft">客户姓名：</td>
            <td>
                <input id="textbox1" name="CustomerName" class="mini-textbox" style="width: 150px;" required="true" /></td>
            <td class="textLeft">电话号码：</td>
            <td>
                <input id="textbox1" name="CPhoneNum" vtype="int" class="mini-textbox" style="width: 150px;" /></td>
            <td class="textLeft">QQ号：</td>
            <td>
                <input id="textbox1" name="CQQ" vtype="int" class="mini-textbox" style="width: 150px;" style="width: 150px;" /></td>
        </tr>
        <tr>
            <td class="textLeft">助记码：</td>
            <td>
                <input id="textbox1" name="MiniCode" class="mini-textbox" style="width: 150px;" /></td>
            <td class="textLeft">手机号码1：</td>
            <td>
                <input id="textbox1" name="CHandPhone1" vtype="int" class="mini-textbox" style="width: 150px;" /></td>
            <td class="textLeft">手机号码2：</td>
            <td>
                <input id="textbox1" name="CHandPhone2" vtype="int" class="mini-textbox" style="width: 150px;" /></td>
            <td class="textLeft">微信号：</td>
            <td>
                <input id="textbox1" name="CWexin" class="mini-textbox" style="width: 150px;" /></td>
        </tr>
        <tr>
            <td class="textLeft">传真：</td>
            <td>
                <input id="textbox1" name="CFax" vtype="int" class="mini-textbox" style="width: 150px;" /></td>
            <td class="textLeft">邮箱：</td>
            <td>
                <input id="textbox1" name="CEmail" vtype="email" class="mini-textbox" style="width: 150px;" /></td>
            <td class="textLeft">法人：</td>
            <td>
                <input id="textbox1" name="CLawyer" class="mini-textbox" style="width: 150px;" /></td>
            <td class="textLeft">财务经理：</td>
            <td>
                <input id="textbox1" name="CFM" class="mini-textbox" style="width: 150px;" /></td>
        </tr>
        <tr>
            <td class="textLeft">业务经理：</td>
            <td>
                <input id="textbox1" name="CBM" class="mini-textbox" style="width: 150px;" /></td>
            <td class="textLeft">客户类型：</td>
            <td>
                <input name="CType" class="mini-combobox" valuefield="DID" textfield="DValue" url="/SystemData/Dict/Get?dtype=@HttpUtility.UrlEncode("客户类型")" style="width: 150px;" />
            </td>
            <td class="textLeft">付款类型：</td>
            <td>
                <input name="CPayType" class="mini-combobox" valuefield="DID" textfield="DValue" url="/SystemData/Dict/Get?dtype=@HttpUtility.UrlEncode("客户付款类型")" style="width: 150px;" />
            </td>
            <td class="textLeft">客户等级：</td>
            <td>
                <input name="CLevel" class="mini-combobox" valuefield="DID" textfield="DValue" url="/SystemData/Dict/Get?dtype=@HttpUtility.UrlEncode("客户等级")" style="width: 150px;" />

            </td>
        </tr>
        <tr>
            <td class="textLeft">信用额度：</td>
            <td>
                <input id="textbox1" name="CreditLimitM" vtype="float" class="mini-textbox" style="width: 150px;" /></td>
            <td class="textLeft">信用天数：</td>
            <td>
                <input id="textbox1" name="CreditLimitD" vtype="int" class="mini-textbox" style="width: 150px;" /></td>
            <td class="textLeft">积分：</td>
            <td>
                <input id="textbox1" name="CScore" vtype="int" class="mini-textbox" style="width: 150px;" />
            </td>
            <td class="textLeft"></td>
            <td>
                <input name="IsServiceFee" class="mini-checkbox" text="是否免服务费" truevalue="true" falsevalue="false" />
            </td>
        </tr>
        <tr>
            <td class="textLeft">银行名称：</td>
            <td colspan="3">
                <input id="textbox1" name="CBankName" class="mini-textbox" style="width: 360px;" /></td>
            <td class="textLeft">银行卡号：</td>
            <td colspan="3">
                <input id="textbox1" name="CBankCardNo" vtype="int" class="mini-textbox" style="width: 360px;" /></td>
        </tr>
        <tr>
            <td class="textLeft">备注：</td>
            <td colspan="3">
                <input id="textbox1" name="Note" class="mini-textbox" style="width: 360px;" /></td>
            <td class="textLeft">客户地址：</td>
            <td colspan="3">
                <input id="textbox1" name="CAddress" class="mini-textbox" style="width: 360px;" /></td>
        </tr>
    </table>
</div>

<script type="text/javascript">

    mini.parse();

    function saveData(e) {

        var _form = new mini.Form("#addData");
        _form.validate();
        if (_form.isValid() == false) return;
        var _data = _form.getData();//获取数组
        var _json = mini.encode(_data);//转换为JSON
        var _post = escape("[" + _json + "]");//把JSON编码
        e.enabled = false;//禁用按钮
        //提交数据
        $.ajax({
            url: "/Customer/Customer/add",
            data: { add: _post },
            type: "post",
            success: function (text, flag, res) {
                if (res.responseText == "") {
                    setEmpty();
                    top.mini.alert("添加成功!");
                }
                else
                    top.mini.alert(res.responseText);
            },
            error: function (text, flag, res) {
                top.mini.alert(res.responseText);
            }
        });
        e.enabled = true;//启用按钮
    }


    function setEmpty() {

    }


</script>
